package com.example.util;

import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Map;

public class start {
    public static void main(String[] args) {
        WordUtils wordUtil=new WordUtils();
        Map<String, Object> params = new HashMap<String, Object>();
        /*params.put("${position}", "java开发");
        params.put("${name}", "焦糖橙子");
        params.put("${sex}", "男");
        params.put("${eMail}", "8888@csdn.com");*/

        try{
            Map<String,Object> jpeg1 = new HashMap<String, Object>();
            jpeg1.put("width", 430);
            jpeg1.put("height", 267);
            jpeg1.put("type", "png");
            //图片位置
            jpeg1.put("content", WordUtils.inputStream2ByteArray(new FileInputStream("/Users/hua/Downloads/饼图示例.png"), true));
            params.put("${jpeg1}",jpeg1);
            /*Map<String,Object>jpeg2 = new HashMap<String, Object>();
            jpeg2.put("width", 100);
            jpeg2.put("height", 150);
            jpeg2.put("type", "jpg");
            jpeg2.put("content", WordUtils.inputStream2ByteArray(new FileInputStream("D:\\text\\dog.jpg"), true));
            params.put("${jpeg2}",jpeg2);*/
            //模板文件位置
            String path="/Users/hua/Desktop/test.docx";
            //生成文件位置
            String fileName= new String("/Users/hua/Desktop/test.docx".getBytes("UTF-8"),"iso-8859-1");
            wordUtil.getWord(path,params,fileName);
        }catch(Exception e){
            e.printStackTrace();
        }
    }


}
